#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {
    vector<vector<int>> res;
    res.resize(2);
    int n = colsum.size();
    res[0].resize(n);
    res[1].resize(n);
    for (int i = 0; i < n; i++)
    {
        if (colsum[i] == 2)
        {
            res[0][i] = res[1][i] = 1;
            upper--;
            lower--;
        }
        else if (colsum[i] == 0)
        {
            res[0][i] = res[1][i] = 0;
        }
        else
        {
            if (upper > lower) res[0][i] = 1, res[1][i] = 0, upper--;
            else res[1][i] = 1, res[0][i] = 0, lower--;
        }
    }
    if (upper || lower) res.resize(0);
    return res;
}

int main()
{
    vector<int> v = { 2,1,2,0,1,0,1,2,0,1 };
    reconstructMatrix(5, 5, v);
    return 0;
}